package com.treegames.rpghelper.sheet;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

import com.treegames.rpghelper.feats.IFeat;
import com.treegames.rpghelper.sheet.classes.IJob;
import com.treegames.rpghelper.sheet.skills.ISkill;

public class CharacterPlayer implements Parcelable {
	/**
	 * 
	 */

	protected String name;
	protected Enum Alignment;
	protected int hitPoints;
	protected int armorClass;
	protected int speed;
	protected int initiative;
	protected SavingThrows savingThrows;
	protected int baseAttackBonus;
	protected int spellResistance;
	protected List<IFeat> feats;
	protected List<ISkill> skills;
	protected int skillPoints;
	protected List<Equipment> equipments;
	protected List<IJob> jobList;
	protected Stats stats;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Enum getAlignment() {
		return Alignment;
	}

	public void setAlignment(Enum alignment) {
		Alignment = alignment;
	}

	public int getHitPoints() {
		return hitPoints;
	}

	public void setHitPoints(int hitPoints) {
		this.hitPoints = hitPoints;
	}

	public int getArmorClass() {
		return armorClass;
	}

	public void setArmorClass(int armorClass) {
		this.armorClass = armorClass;
	}

	public int getSpeed() {
		return speed;
	}

	public void setSpeed(int speed) {
		this.speed = speed;
	}

	public int getInitiative() {
		return initiative;
	}

	public void setInitiative(int initiative) {
		this.initiative = initiative;
	}

	public SavingThrows getSavingThrows() {
		return savingThrows;
	}

	public void setSavingThrows(SavingThrows savingThrows) {
		this.savingThrows = savingThrows;
	}

	public int getBaseAttackBonus() {
		return baseAttackBonus;
	}

	public void setBaseAttackBonus(int baseAttackBonus) {
		this.baseAttackBonus = baseAttackBonus;
	}

	public int getSpellResistance() {
		return spellResistance;
	}

	public void setSpellResistance(int spellResistance) {
		this.spellResistance = spellResistance;
	}

	public List<IFeat> getFeats() {
		return feats;
	}

	public void setFeats(List<IFeat> feats) {
		this.feats = feats;
	}

	public List<ISkill> getSkills() {
		return skills;
	}

	public void setSkills(List<ISkill> skills) {
		this.skills = skills;
	}

	public int getSkillPoints() {
		return skillPoints;
	}

	public void setSkillPoints(int skillPoints) {
		this.skillPoints = skillPoints;
	}

	public List<Equipment> getEquipments() {
		return equipments;
	}

	public void setEquipments(List<Equipment> equipments) {
		this.equipments = equipments;
	}

	public Stats getStats() {
		return stats;
	}

	public void setStats(Stats stats) {
		this.stats = stats;
	}

	public List<IJob> getJobList() {
		return jobList;
	}

	public void setJobList(ArrayList<IJob> jobList) {
		this.jobList = jobList;
	}

	public void levelUp(IJob job) {
		job.levelUp(this);
		this.jobList.add(job);
	}

	public CharacterPlayer() {
		setStats(new Stats());
		this.feats = new ArrayList<IFeat>();
		this.jobList = new ArrayList<IJob>();
	}

	public CharacterPlayer(Parcel in) {
		readFromParcel(in);
	}

	private void readFromParcel(Parcel in) {
		//
		// protected String name;
		// protected Enum Alignment;
		// protected int hitPoints;
		// protected int armorClass;
		// protected int speed;
		// protected int initiative;
		// protected SavingThrows savingThrows;
		// protected int baseAttackBonus;
		// protected int spellResistance;
		// protected List<IFeat> feats;
		// protected List<ISkill> skills;
		// protected int skillPoints;
		// protected List<Equipment> equipments;
		// protected List<Job> jobList;
		// protected Stats stats;
		//
		this.name = in.readString();
		this.Alignment = in.readParcelable(Enum.class.getClassLoader());
		this.hitPoints = in.readInt();
		this.armorClass = in.readInt();
		this.speed = in.readInt();
		this.initiative = in.readInt();
		this.savingThrows = in.readParcelable(SavingThrows.class
				.getClassLoader());
		this.baseAttackBonus = in.readInt();
		this.spellResistance = in.readInt();
		this.feats = in.readArrayList(IFeat.class.getClassLoader());
		this.skills = in.readArrayList(ISkill.class.getClassLoader());
		this.skillPoints = in.readInt();
		this.equipments = in.readArrayList(Equipment.class.getClassLoader());
		this.jobList = in.readArrayList(IJob.class.getClassLoader());
		this.stats = in.readParcelable(Stats.class.getClassLoader());

	}

	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeString(name);
		dest.writeParcelable((Parcelable) Alignment, flags);
		dest.writeInt(hitPoints);
		dest.writeInt(armorClass);
		dest.writeInt(speed);
		dest.writeInt(initiative);
		dest.writeParcelable((Parcelable) savingThrows, flags);
		dest.writeInt(baseAttackBonus);
		dest.writeInt(spellResistance);
		//dest.writeList(feats);
		//dest.writeList(skills);
		dest.writeInt(skillPoints);
		dest.writeList(equipments);
		// dest.writeList(jobList);
		// dest.writeParcelable((Parcelable) stats,flags);

	}

	public static final Parcelable.Creator<CharacterPlayer> CREATOR = new Parcelable.Creator<CharacterPlayer>() {
		public CharacterPlayer createFromParcel(Parcel in) {
			return new CharacterPlayer(in);
		}

		public CharacterPlayer[] newArray(int size) {
			return new CharacterPlayer[size];
		}
	};
}
